package com.huitian.net.utils;
import java.sql.*;

public class MysqlUtils {

    //delete_dws_saleinvoice_in_salor_nc_m
    public static void delete_dws_saleinvoice_in_salor_nc_m(String month,String lastmonth) throws SQLException {
        //注册驱动    使用驱动连接数据库
        Connection con = null;
        Statement stmt = null;
        ResultSet rs = null;
        try {
            String driver = "com.mysql.jdbc.Driver";   //加载驱动
            String url = "jdbc:mysql://192.168.200.175:3306/nc?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false&useSSL=false";
            String user = "nc";
            String pass = "ht123456";
            Class.forName(driver);
            con = DriverManager.getConnection(url, user, pass);
            stmt = con.createStatement();

//            String sql = "delete from nnp_day where day = " + day;
            String sql = "delete from  dws_saleinvoice_in_salor_nc_m where month<="+month+" and month>="+lastmonth;
            String sql2 = "commit;";
            int result = stmt.executeUpdate(sql);
            int result2 = stmt.executeUpdate(sql2);
            if (result > 0) {
                System.out.println("删除成功");
            } else {
                System.out.println("删除失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            con.close();
        }
    }
    //dwd_saleinvoice_nc
    public static void delete_dwd_saleinvoice_nc(String day,String lastday) throws SQLException {
        //注册驱动    使用驱动连接数据库
        Connection con = null;
        Statement stmt = null;
        ResultSet rs = null;
        try {
            String driver = "com.mysql.jdbc.Driver";   //加载驱动
            String url = "jdbc:mysql://192.168.200.175:3306/nc?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false&useSSL=false";
            String user = "nc";
            String pass = "ht123456";
            Class.forName(driver);
            con = DriverManager.getConnection(url, user, pass);
            stmt = con.createStatement();

            String sql = "delete from  dwd_saleinvoice_nc where day<="+day+" and day>="+lastday;
            System.out.println("sql:  "+sql);
            String sql2 = "commit;";
            int result = stmt.executeUpdate(sql);
            int result2 = stmt.executeUpdate(sql2);
            if (result > 0) {
                System.out.println("删除成功");
            } else {
                System.out.println("删除失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            con.close();
        }
    }

    //dws_delivery_in_salor_nc_w
    public static void delete_dws_delivery_in_salor_nc_w(String day,String lastday) throws SQLException {
        //注册驱动    使用驱动连接数据库
        Connection con = null;
        Statement stmt = null;
        ResultSet rs = null;
        try {
            String driver = "com.mysql.jdbc.Driver";   //加载驱动
            String url = "jdbc:mysql://192.168.200.175:3306/nc?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false&useSSL=false";
            String user = "nc";
            String pass = "ht123456";
            Class.forName(driver);
            con = DriverManager.getConnection(url, user, pass);
            stmt = con.createStatement();

            String sql = "delete from  dws_delivery_in_salor_nc_w where month<="+day+" and month>="+lastday;
            System.out.println("sql:  "+sql);
            String sql2 = "commit;";
            int result = stmt.executeUpdate(sql);
            int result2 = stmt.executeUpdate(sql2);
            if (result > 0) {
                System.out.println("删除成功");
            } else {
                System.out.println("删除失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            con.close();
        }
    }

    //dwd_delivery_nc
    public static void delete_dwd_delivery_nc(String day,String lastday) throws SQLException {
        //注册驱动    使用驱动连接数据库
        Connection con = null;
        Statement stmt = null;
        ResultSet rs = null;
        try {
            String driver = "com.mysql.jdbc.Driver";   //加载驱动
            String url = "jdbc:mysql://192.168.200.175:3306/nc?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false&useSSL=false";
            String user = "nc";
            String pass = "ht123456";
            Class.forName(driver);
            con = DriverManager.getConnection(url, user, pass);
            stmt = con.createStatement();

            String sql = "delete from  dwd_delivery_nc where day<="+day+" and day>="+lastday;
            System.out.println("sql:  "+sql);
            String sql2 = "commit;";
            int result = stmt.executeUpdate(sql);
            int result2 = stmt.executeUpdate(sql2);
            if (result > 0) {
                System.out.println("删除成功");
            } else {
                System.out.println("删除失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            con.close();
        }
    }

    //dws_tab_fhinfo_hb_nc_m
    public static void delete_dws_tab_fhinfo_hb_nc_m(String month,String lastmonth) throws SQLException {
        //注册驱动    使用驱动连接数据库
        Connection con = null;
        Statement stmt = null;
        ResultSet rs = null;
        try {
            String driver = "com.mysql.jdbc.Driver";   //加载驱动
            String url = "jdbc:mysql://192.168.200.175:3306/nc?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false&useSSL=false";
            String user = "nc";
            String pass = "ht123456";
            Class.forName(driver);
            con = DriverManager.getConnection(url, user, pass);
            stmt = con.createStatement();

//            String sql = "delete from nnp_day where day = " + day;
            String sql = "truncate table dws_tab_fhinfo_hb_nc_m";
            System.out.println("sql:  "+sql);
            String sql2 = "commit;";
            int result = stmt.executeUpdate(sql);
            int result2 = stmt.executeUpdate(sql2);
            if (result > 0) {
                System.out.println("删除成功");
            } else {
                System.out.println("删除失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            con.close();
        }
    }
    //dwd_saleinvoice_custome_industry_nc_d
    public static void delete_dwd_saleinvoice_custome_industry_nc_d(String day,String lastday) throws SQLException {
        //注册驱动    使用驱动连接数据库
        Connection con = null;
        Statement stmt = null;
        ResultSet rs = null;
        try {
            String driver = "com.mysql.jdbc.Driver";   //加载驱动
            String url = "jdbc:mysql://192.168.200.175:3306/nc?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false&useSSL=false";
            String user = "nc";
            String pass = "ht123456";
            Class.forName(driver);
            con = DriverManager.getConnection(url, user, pass);
            stmt = con.createStatement();

//            String sql = "delete from nnp_day where day = " + day;
            String sql = "delete from  dwd_saleinvoice_custome_industry_nc_d where day<="+day+" and day>="+lastday;
            System.out.println("sql:  "+sql);
            String sql2 = "commit;";
            int result = stmt.executeUpdate(sql);
            int result2 = stmt.executeUpdate(sql2);
            if (result > 0) {
                System.out.println("删除成功");
            } else {
                System.out.println("删除失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            con.close();
        }
    }


    //dws_delivery_in_industry_nc_m
    public static void delete_dws_delivery_in_industry_nc_m(String day,String lastday) throws SQLException {
        //注册驱动    使用驱动连接数据库
        Connection con = null;
        Statement stmt = null;
        ResultSet rs = null;
        try {
            String driver = "com.mysql.jdbc.Driver";   //加载驱动
            String url = "jdbc:mysql://192.168.200.175:3306/nc?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false&useSSL=false";
            String user = "nc";
            String pass = "ht123456";
            Class.forName(driver);
            con = DriverManager.getConnection(url, user, pass);
            stmt = con.createStatement();

//            String sql = "delete from nnp_day where day = " + day;
            String sql = "delete from  dws_delivery_in_industry_nc_m where month<="+day+" and month>="+lastday;
            System.out.println("sql:  "+sql);
            String sql2 = "commit;";
            int result = stmt.executeUpdate(sql);
            int result2 = stmt.executeUpdate(sql2);
            if (result > 0) {
                System.out.println("删除成功");
            } else {
                System.out.println("删除失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            con.close();
        }
    }


    //dws_delivery_in_industry_nc_d
    public static void delete_dws_delivery_in_industry_nc_d(String day,String lastday) throws SQLException {
        //注册驱动    使用驱动连接数据库
        Connection con = null;
        Statement stmt = null;
        ResultSet rs = null;
        try {
            String driver = "com.mysql.jdbc.Driver";   //加载驱动
            String url = "jdbc:mysql://192.168.200.175:3306/nc?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false&useSSL=false";
            String user = "nc";
            String pass = "ht123456";
            Class.forName(driver);
            con = DriverManager.getConnection(url, user, pass);
            stmt = con.createStatement();

//            String sql = "delete from nnp_day where day = " + day;
            String sql = "delete from  dws_delivery_in_industry_nc_d where day<="+day+" and day>="+lastday;
            System.out.println("sql:  "+sql);
            String sql2 = "commit;";
            int result = stmt.executeUpdate(sql);
            int result2 = stmt.executeUpdate(sql2);
            if (result > 0) {
                System.out.println("删除成功");
            } else {
                System.out.println("删除失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            con.close();
        }
    }


    //dws_saleinvoice_in_customer_nc_d
    public static void delete_dws_saleinvoice_in_customer_nc_d(String day,String lastday) throws SQLException {
        //注册驱动    使用驱动连接数据库
        Connection con = null;
        Statement stmt = null;
        ResultSet rs = null;
        try {
            String driver = "com.mysql.jdbc.Driver";   //加载驱动
            String url = "jdbc:mysql://192.168.200.175:3306/nc?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false&useSSL=false";
            String user = "nc";
            String pass = "ht123456";
            Class.forName(driver);
            con = DriverManager.getConnection(url, user, pass);
            stmt = con.createStatement();

//            String sql = "delete from nnp_day where day = " + day;
            String sql = "delete from  dws_saleinvoice_in_customer_nc_d where day<="+day+" and day>="+lastday;
            System.out.println("sql:  "+sql);
            String sql2 = "commit;";
            int result = stmt.executeUpdate(sql);
            int result2 = stmt.executeUpdate(sql2);
            if (result > 0) {
                System.out.println("删除成功");
            } else {
                System.out.println("删除失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            con.close();
        }
    }

    //dws_saleinvoice_in_salor_nc_d
    public static void delete_dws_saleinvoice_in_salor_nc_d(String day,String lastday) throws SQLException {
        //注册驱动    使用驱动连接数据库
        Connection con = null;
        Statement stmt = null;
        ResultSet rs = null;
        try {
            String driver = "com.mysql.jdbc.Driver";   //加载驱动
            String url = "jdbc:mysql://192.168.200.175:3306/nc?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false&useSSL=false";
            String user = "nc";
            String pass = "ht123456";
            Class.forName(driver);
            con = DriverManager.getConnection(url, user, pass);
            stmt = con.createStatement();

//            String sql = "delete from nnp_day where day = " + day;
            String sql = "delete from  dws_saleinvoice_in_salor_nc_d where day<="+day+" and day>="+lastday;
            String sql2 = "commit;";
            int result = stmt.executeUpdate(sql);
            int result2 = stmt.executeUpdate(sql2);
            if (result > 0) {
                System.out.println("删除成功");
            } else {
                System.out.println("删除失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            con.close();
        }
    }



    public static void delete(String day,String lastday) throws SQLException {
        //注册驱动    使用驱动连接数据库
        Connection con = null;
        Statement stmt = null;
        ResultSet rs = null;
        try {
            String driver = "com.mysql.jdbc.Driver";   //加载驱动
            String url = "jdbc:mysql://192.168.200.175:3306/nc?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false&useSSL=false";
            String user = "nc";
            String pass = "ht123456";
            Class.forName(driver);
            con = DriverManager.getConnection(url, user, pass);
            stmt = con.createStatement();
            
//            String sql = "delete from nnp_day where day = " + day;
            String sql = "delete from  dws_delivery_in_salor_nc_d where day<="+day+" and day>="+lastday;
            String sql2 = "commit;";
            int result = stmt.executeUpdate(sql);
            int result2 = stmt.executeUpdate(sql2);
            if (result > 0) {
                System.out.println("删除成功");
            } else {
                System.out.println("删除失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            con.close();
        }
    }
    //dws_saleinvoice_in_customer_nc_m
    public static void delete_dws_saleinvoice_in_customer_nc_m(String month,String lastmonth) throws SQLException {
        //注册驱动    使用驱动连接数据库
        Connection con = null;
        Statement stmt = null;
        ResultSet rs = null;
        try {
            String driver = "com.mysql.jdbc.Driver";   //加载驱动
            String url = "jdbc:mysql://192.168.200.175:3306/nc?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false&useSSL=false";
            String user = "nc";
            String pass = "ht123456";
            Class.forName(driver);
            con = DriverManager.getConnection(url, user, pass);
            stmt = con.createStatement();

//            String sql = "delete from nnp_day where day = " + day;
            String sql = "delete from  dws_saleinvoice_in_customer_nc_m where month>="+lastmonth+" and month<="+month;
            System.out.println("sql====:"+sql);
            String sql2 = "commit;";
            int result = stmt.executeUpdate(sql);
            int result2 = stmt.executeUpdate(sql2);
            if (result > 0) {
                System.out.println("删除成功");
            } else {
                System.out.println("删除失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            con.close();
        }
    }

    //dws_saleinvoice_in_industry_nc_m
    public static void delete_dws_saleinvoice_in_industry_nc_m(String month,String lastmonth) throws SQLException {
        //注册驱动    使用驱动连接数据库
        Connection con = null;
        Statement stmt = null;
        ResultSet rs = null;
        try {
            String driver = "com.mysql.jdbc.Driver";   //加载驱动
            String url = "jdbc:mysql://192.168.200.175:3306/nc?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false&useSSL=false";
            String user = "nc";
            String pass = "ht123456";
            Class.forName(driver);
            con = DriverManager.getConnection(url, user, pass);
            stmt = con.createStatement();

//            String sql = "delete from nnp_day where day = " + day;
            String sql = "delete from  dws_saleinvoice_in_industry_nc_m where month>="+lastmonth+" and month<="+month;
            System.out.println("sql====:"+sql);
            String sql2 = "commit;";
            int result = stmt.executeUpdate(sql);
            int result2 = stmt.executeUpdate(sql2);
            if (result > 0) {
                System.out.println("删除成功");
            } else {
                System.out.println("删除失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            con.close();
        }
    }

    //dws_saleinvoice_in_industry_nc_d
    public static void delete_dws_saleinvoice_in_industry_nc_d(String month,String lastmonth) throws SQLException {
        //注册驱动    使用驱动连接数据库
        Connection con = null;
        Statement stmt = null;
        ResultSet rs = null;
        try {
            String driver = "com.mysql.jdbc.Driver";   //加载驱动
            String url = "jdbc:mysql://192.168.200.175:3306/nc?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false&useSSL=false";
            String user = "nc";
            String pass = "ht123456";
            Class.forName(driver);
            con = DriverManager.getConnection(url, user, pass);
            stmt = con.createStatement();

//            String sql = "delete from nnp_day where day = " + day;
            String sql = "delete from  dws_saleinvoice_in_industry_nc_d where day>="+lastmonth+" and day<="+month;
            System.out.println("sql====:"+sql);
            String sql2 = "commit;";
            int result = stmt.executeUpdate(sql);
            int result2 = stmt.executeUpdate(sql2);
            if (result > 0) {
                System.out.println("删除成功");
            } else {
                System.out.println("删除失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            con.close();
        }
    }


    public static void delete_dws_delivery_in_salor_nc_m(String month,String lastmonth) throws SQLException {
        //注册驱动    使用驱动连接数据库
        Connection con = null;
        Statement stmt = null;
        ResultSet rs = null;
        try {
            String driver = "com.mysql.jdbc.Driver";   //加载驱动
            String url = "jdbc:mysql://192.168.200.175:3306/nc?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false&useSSL=false";
            String user = "nc";
            String pass = "ht123456";
            Class.forName(driver);
            con = DriverManager.getConnection(url, user, pass);
            stmt = con.createStatement();

//            String sql = "delete from nnp_day where day = " + day;
            String sql = "delete from  dws_delivery_in_salor_nc_m where month>="+lastmonth+" and month<="+month;
            System.out.println("sql====:"+sql);
            String sql2 = "commit;";
            int result = stmt.executeUpdate(sql);
            int result2 = stmt.executeUpdate(sql2);
            if (result > 0) {
                System.out.println("删除成功");
            } else {
                System.out.println("删除失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            con.close();
        }
    }



}
